/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.yxw.live_vod_backend_boot.enums;

import com.yxw.yxnet_cd_center.common.constant.CommonConstant;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * mqtt 主题枚举
 * @author lx
 * 2023.10.7
 */
public enum MqttTopicEnum {

    /**
     * 页面订阅主题
     */

    /**
     * 系统订阅主题,多用于延迟消息队列
     */
    SYSTEM_OFFLINE_TOPIC("live_sys_offline_",CommonConstant.MQTT_SERVER_TOPIC,"用户登录强制下线主题");

    MqttTopicEnum(String topic,String topicType,String describe) {
        this.topic = topic;
        this.topicType = topicType;
        this.describe = describe;
    }

    /**
     * 主题前缀
     */
    @Getter
    private String topic;

    /**
     * 主题类型
     * server:服务端订阅主题
     *client:客户端订阅主题
     */
    @Getter
    private String topicType;
    /**
     * 主题前缀描述
     */
    @Getter
    private String describe;

    /**
     * 初始化延迟消息队列
     * @return
     */
    public static List<String> getSeverTopicList(){
        ArrayList<String> topicList = new ArrayList<>();
        for (MqttTopicEnum topicEnum : values()) {
            if (topicEnum.getTopic().equals(CommonConstant.MQTT_SERVER_TOPIC)) {
                topicList.add("$share/delay/".concat(topicEnum.getTopic().concat("+")));
            }
        }
        return topicList;
    }

    /**
     * 获取客户端订阅主题列表
     */
    public static List<String> getClientTopicList(){
        ArrayList<String> topicList = new ArrayList<>();
        for (MqttTopicEnum topicEnum : values()) {
            if (topicEnum.getTopic().equals(CommonConstant.MQTT_CLIENT_TOPIC)) {
                topicList.add(topicEnum.getTopic());
            }
        }
        return topicList;
    }
}
